﻿import { customRef } from 'vue';

export const loading = customRef((track, trigger) => {
    let count = 0;

    return {
        get() {
            track(); // 追踪依赖
            return count > 0;
        },
        set(val) {
            count += val ? 1 : -1;
            count = Math.max(0, count);
            trigger(); //触发更新
        },
    };
});
